<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">

                <f:view>


                    <h:form>
                        <p:panel >

                            <f:facet name="header" >
                                <h:outputLabel value="Manage User"/>
                                <p:commandButton ajax="false" value="Save" action="#{webUserController.saveUser()}" >
                                </p:commandButton>

                                <p:commandButton ajax="false" value="Back" action="#{webUserController.backToViewUsers()}" >
                                </p:commandButton>

                            </f:facet>

                            <p:panelGrid columns="2">
                                <p:outputLabel value="User Name:" for="name" />
                                <p:outputLabel id="name" value="#{webUserController.current.name}" />

                                <p:outputLabel value="Staff:" for="staff" />
                                <p:autoComplete  forceSelection="true" id="staff"
                                                 value="#{webUserController.current.staff}" 
                                                 completeMethod="#{staffController.completeStaff}" 
                                                 var="mys" 
                                                 itemLabel="#{mys.person.nameWithTitle}" 
                                                 itemValue="#{mys}"
                                                 converter="stfcon">
                                </p:autoComplete>

                                <p:outputLabel value="Institution:" for="institution" />
                                <p:autoComplete forceSelection="true" value="#{webUserController.current.institution}"
                                                completeMethod="#{institutionController.completeIns}" id="institution"
                                                var="ix" itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  >
                                    <f:ajax event="itemSelect" execute="@this" render="department" ></f:ajax>
                                </p:autoComplete>


                                <p:outputLabel value="Department:" for="department" />
                                <p:selectOneMenu id="department" value="#{webUserController.current.department}" >
                                    <f:selectItems value="#{departmentController.items}"/>
                                </p:selectOneMenu>

                                <p:outputLabel value="Email:" for="email" />
                                <p:inputText id="email" value="#{webUserController.current.email}" title="Email" />
                                <p:outputLabel value="TelNo:" for="telNo" />
                                <p:inputText id="telNo" value="#{webUserController.current.telNo}" title="TelNo" />
                                <p:outputLabel value="Code:" for="code" />
                                <p:inputText id="code" value="#{webUserController.current.code}" title="Code" />
                            </p:panelGrid>
                        </p:panel>

                    </h:form>
                </f:view>



            </ui:define>

        </ui:composition>

    </h:body>
</html>
